<template>
  <div>
    <div class="header">
      <a href="/">
        <i class="el-icon-video-camera"></i>
        <span class="tinyvideo">Six 微视频</span>
      </a>
      <el-dropdown @command="handleCommand">
        <span class="el-dropdown-link">
          {{administrator.nickname}}
          <i class="el-icon-arrow-down el-icon--right"></i>
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item icon="el-icon-switch-button" command="a">退出系统</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </div>
</template>

<script>
import {getAdminInfo,logout} from "@/api/login"
export default {

  data(){
    return{
      administrator:[]
    }
  },

  created(){
    this.fetchData();
  },

  methods:{
    handleCommand(command) {
        switch(command){
          case 'a':
            logout(command).then(response=>{
              const reps = reaponse.data;
              this.$router.push({ path: "/login" });
            });
            break;
          default: 
            break;
        }
      },
      fetchData(){
        getAdminInfo().then(response=>{
          console.log(response)
          this.administrator =response.data.data.administrator;
        })
      }
  }

}
</script>
<style scoped>
.header{
    position: absolute;
    line-height: 60px;
    background-color:  #2d3a4b;
    top: 0px;
    left:0px;
    right:0px; 
}
.el-icon-video-camera {
  font-size: 40px;
  color: white;
  vertical-align: middle;
  line-height: 40px;
  padding: 0 20px 0 100px;
}
.tinyvideo {
  position: absolute;
  color: white;
}
.el-dropdown{
  clear: both;
  float: right;
  margin-right: 40px;
  color:white;
  cursor: pointer;
  color: white;
}
.el-icon-arrow-down {
  font-size: 12px;
}
</style>